<template>
  <div class="index">
    <div class="wrap" v-loading="loading">
      <!-- <div class="crumbs flex"><div class="p">首页</div><div class="p" v-if="parent.meta">>{{ parent.meta.title }}</div><div class="p">>{{title}}</div></div> -->
      <div class="crumbs flex">
            <router-link to="/" class="p">首页</router-link>
            <router-link class="p" :to="parent.path" v-if="parent.meta">>{{ parent.meta.title }}</router-link>
            <div class="p">>{{title}}</div>
          </div>
      <div class="list">
        <div class="li flex-bet" v-for="(item,i) in list" :key="i" @click="togNav('/service/activitydetails?id='+item.id)">
          <div class="img" :style="{background: 'url('+item.imgUrl+') center center no-repeat',backgroundSize:'cover'}"></div>
          <div class="info">
            <div class="title">
              {{item.title}}
            </div>
            <div class="p1">
              {{item.abstractDesc}}
            </div>
            <div class="date">{{item.releaseTime}}</div>
          </div>
        </div>
      </div>
      <el-pagination
        background
        prev-text="上一页"
        next-text="下一页"
        layout="prev, pager, next"
        @current-change="curPage"
        :page-size="req.limit"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>
<script>
import { activityfindAllList } from "@/api/service/service";
export default {
  name: "index",
  data() {
    return {
      parent: {}, //获取父路由信息
      title: "",
      total:0,
      req:{
        page:1,
        limit:10
      },
      img: require("../../assets/image/profile.jpg"),
      list: [], //数据列表
      loading:false
    };
  },
  created() {},
  mounted() {
    this.parent = this.$route.matched[0];
    this.title = this.$route.meta.title;
    this.activityfindAllListapi()
  },
  methods: {
    togNav(e) {
      this.$router.push(e);
    },
    getQueryString(name) {
      let reg = `(^|&)${name}=([^&]*)(&|$)`;
      let r = window.location.search.substr(1).match(reg);
      if (r != null) return unescape(r[2]);
      return null;
    },
    activityfindAllListapi() {
      this.loading = true;
      activityfindAllList(this.req).then((res) => {
        this.loading = false;
        this.total = res.total;
        this.list = res.data;

      });
    },
    curPage(e) {
      this.req.page = e;
      this.activityfindAllListapi()
    },
  },
};
</script>
<style scoped>
.index {
  background: #fff;
}
.crumbs {
  padding: 10px 0 0 0;
}
.crumbs .p {
  font-size: 14px;
}
.service-title {
  padding: 36px 0 0 0;
  text-align: center;
  color: #5e9f8e;
}
.service-title h2 {
  font-size: 36px;
  line-height: 52px;
}
.service-title p {
  font-size: 14px;
  line-height: 24px;
  text-transform: uppercase;
}
.nav {
  padding: 0;
}
.nav li {
  font-size: 16px;
  color: #343434;
  line-height: 20px;
  padding: 0 15px;
  transition: all 0.5s;
}
.nav li.on {
  color: #ce3a5c;
}
.nav li:hover {
  color: #ce3a5c;
}
.list {
  padding: 24px 0;
}
.list .li {
  padding: 30px 0;
  border-bottom: 1px solid #eee;
}
.list .li .img {
  background: #eee;
  width: 200px;
  height: 135px;
  flex-shrink: 0;
  flex-grow: 0;
}
.list .li .info {
  padding-left: 20px;
  flex: 1;
}
.list .li .info .title {
  font-size: 18px;
  color: #111;
  line-height: 20px;
  padding: 16px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: bold;
}
.list .li .info .p1 {
  font-size: 14px;
  color: #777;
  line-height: 22px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.list .li .info .date {
  padding-top: 12px;
  font-size: 14px;
  color: #bbbbbb;
  line-height: 28px;
}
.el-pagination button{
    cursor: pointer;
    outline: none;
    width: 70px;
    height: 30px;
    background: #ffffff;
    border: 1px solid #ebebeb;
    border-radius: 4px;
    font-size: 14px;
    color: #777777;
    margin-left: 5px;
    margin-right: 5px;
    font-weight: 400;
}
</style>
<style lang="scss" scoped>
>>> .el-pagination {
  padding: 50px 0 80px 0;
  text-align: center;

  button {
    cursor: pointer;
    outline: none;
    width: 70px;
    height: 30px;
    background-color: #ffffff;
    border: 1px solid #ebebeb;
    border-radius: 4px;
    font-size: 14px;
    color: #777777;
    margin-left: 5px;
    margin-right: 5px;
    font-weight: 400;
    &:disabled {
      color: #bbbbbb;
    }
  }
  .btn-prev{
    background-color: #ffffff;
  }
  .btn-next{
    background-color: #ffffff;
  }
  .el-pager {
    .number {
      background: #ffffff;
      border: 1px solid #ebebeb;
      font-weight: normal;
      width: 30px;
      height: 30px;
      color: #777777;
      &.active {
        background: #3dabc4;
        border-radius: 4px;
        color: white;
      }
    }
    .el-icon{
      background-color: #fff;
    }
  }
}
</style>